@nexssp/ensure
NEW: 02.04.2022 Added workflows + support for MacOS.
nexssp-ensure git
It's more then @nexssp/os function as it has translator
. What it means? that for example on Gentoo to install git you need to put emerge dev-vcs/git
(not git). We cover that in the @nexssp/extend. We will be building the database of what and which distro what kind of changes has. For example:
Translator file example
Git
Below is just: All Gentoos use 'dev-vcs/git'.
const os = require('@nexssp/os/legacy')
const GentooFirst = os.getTags(os.distros.GENTOO, 1).first()
module.exports = {
[GentooFirst]: 'dev-vcs/git',
}
const result = ensureInstalled("git") => it will automatically install git on your machine
-
Function just make sure your program is installed (Linux, WSL, Windows) and macOS soon..
-
This package is used in many packages. For example in the @nexssp/languages where you can install over 50 programming languages. Try npx @nexssp/languages r install
or npx @nexssp/languages php install
.
API
Functions
ensureInstalled(command/package, installCommand, options)
which(command)
- returns path of the command/program, false if does not exist.
Examples
const { ensureInstalled } = require('@nexssp/ensure')
const path = ensureInstalled('jq', 'apt install jq', {
progress: cliArgs.progress,
})
const path2 = ensureInstalled('lua', {
progress: cliArgs.progress,
})
const path3 = ensureInstalled('wsl jq', 'wsl -u root apt install jq')
CLI tool
nexssp-ensure jq --install="apt install jq"
nexssp-ensure "wsl jq" --install="wsl -u root apt install jq"
Development
Translator files
Example 1
When ensure installing the packages it is looking at the translator files. Here are the examples:
const os = require('@nexssp/os/legacy')
const Windows = os.getTags(os.distros.WINDOWS, 1).first()
module.exports = {
[Windows]: {
install: `powershell -command "Set-ExecutionPolicy RemoteSigned -scope CurrentUser" ; powershell -command "iex (new-object net.webclient).downloadstring('https://get.scoop.sh')"`,
},
}
Example 2
const os = require('@nexssp/os/legacy')
const GentooFirst = os.getTags(os.distros.GENTOO, 1).first()
module.exports = {
[GentooFirst]: 'dev-vcs/git',
}